package com.tbsoft.ehr.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import com.opensymphony.xwork2.ActionContext;
import com.tbsoft.ehr.login.LoginInfo;

@MappedSuperclass
public abstract class BaseEntity implements Serializable {

	// 对象状态（新增A，修改U，删除D）
	private String status = "A";
	
	private String updateBy ;
	private Date createTime = new Date(System.currentTimeMillis());
	private Date updateTime ;
	
	private String keyword;

	@Column(name="STATUS",length=4)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name="UPDATE_BY",length=50)
	public String getUpdateBy() {
		if(updateBy ==null || updateBy.isEmpty()){
			try{				
				updateBy=((LoginInfo)ActionContext.getContext().getSession().get("loginInfo")).getUserId();
			}catch(Exception e){
				updateBy="";
			}
		}
		return updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	@Column(name="CREATE_TIME",columnDefinition="datetime",updatable=false)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name="UPDATE_TIME",columnDefinition="timestamp")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Transient
	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	

}
